/**
 * 
 */
package cn.ivicar.app.controller.event;

import org.codehaus.plexus.util.StringUtils;

import cn.com.carsmart.ws.guice.GuiceConfig;
import cn.ivicar.redis.pubsub.MessageHander;
import net.sf.json.JSONObject;

/**
 *
 * @author liurunbin 2017年7月9日 cn.ivicar.message.push.controller
 */
public class CloudEventHander implements MessageHander {

	private EventController eventController = GuiceConfig.getStaticInjector().getInstance(EventController.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.ivicar.redis.pubsub.MessageHander#handle(java.lang.String)
	 */
	@Override
	public void handle(String message) {
		if (StringUtils.isBlank(message)) {
			return;
		}

		JSONObject receive = JSONObject.fromObject(message);
		if (receive == null || receive.isEmpty()) {
			return;
		}

		try {
			eventController.process(receive);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
